home *** CD-ROM | disk | FTP | other *** search
- From: clamage@eng.sun.com (Steve Clamage)
- Message-ID: <4f8o3i$hb6@engnews1.Eng.Sun.COM>
- X-Original-Date: 6 Feb 1996 23:26:42 GMT
- Path: in2.uu.net!bounce-back
- Date: 07 Feb 96 01:50:16 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: Forward declaration of a sub-class?
- Organization: Sun Microsystems Inc.
- References: <199602062218.RAA08320@pythagoras.csc.ncsu.edu>
- Reply-To: clamage@eng.sun.com
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMRgFoeEDnX0m9pzZAQGkmgF+I/GbO4LK3Hd+wJfZ0A4Tm9XoTUDGjCny
- r9RwFGB/sBUpjlXVPuPnXBQDFvLgfPw6
- =5LSM
-
- In article RAA08320@pythagoras.csc.ncsu.edu, bwmott@unity.ncsu.edu writes:
- >
- >I've got a question about forward declaring a class as a sub-class of
- >another class. Is it possible under the C++ draft standard to do
- >something like:
- >
- > class S;
- > class T : public S;
-
- No, for several reasons.
-
- You cannot mention class internals until the definition of the class has
- been seen. You could otherwise in principle add things to a class
- without modifying the class definition. (Some languages allow you to
- do so, but C++ does not.)
-
- Knowing only that T is derived from S is not any more helpful than knowing
- only that T is a class. For example, casting a T* to an S* or the reverse
- in general requires the full class definitions.
-
- Your example involved covariant return types. The compiler can't generate
- the appropriate pointer adjustments without seeing the class definitions.
- ---
- Steve Clamage, stephen.clamage@eng.sun.com
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. Moderation policy:
- http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
-